/**
 * @properties={typeid:35,uuid:"98899CF5-1388-4905-97C4-953536F1A477",variableType:6}
 */
var fImpMin = 0;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"E2018D6C-6106-4639-97E5-070BC5232A1F"}
 */
function continuar(event) {
	var $query 	= 'select p.razon_social as "razon_social_", sum(cc.importe_signo) as "importe_",sum(cc.saldo_signo) as "saldo_", sum(cc.importe_signo) - sum(cc.saldo_signo) as "diferencia" '
					+ 'from ctacte_pr as "cc" join proveedor as "p" on p.proveedor_id = cc.proveedor_id '
					+ 'group by p.razon_social order by p.razon_social'
	var $max 	= -1
	var $args 	= null
	var $ds		= databaseManager.getDataSetByQuery('infocom',$query,$args,$max)
	$ds.sort(4,true)
	
	var i = 1
	while (Math.abs($ds.getValue(i,4)) < fImpMin)
	{
		$ds.removeRow(i)
	}
	//$ds.removeColumn(4)
	crearFormLista($ds)
}

/**
 * @properties={typeid:24,uuid:"A678891B-9061-4319-A30E-A77A41CC4662"}
 */
function crearFormLista($ds)
{
	var $nombre		= 'control_saldos_tab'
	
	elements.tab_lista.removeAllTabs()
	history.removeForm($nombre)
	solutionModel.removeForm($nombre)
	
	var tipos 		= new Array(JSColumn.TEXT,JSColumn.NUMBER,JSColumn.NUMBER,JSColumn.NUMBER)
	var dSource 	= $ds.createDataSource('LISTA', tipos)
	var frm 		= solutionModel.newForm($nombre,dSource,null,null,false,350,20)
	frm.dataSource 	= dSource
	frm.view 		= JSForm.LOCKED_TABLE_VIEW
	
	var $fld_1 = frm.newField('razon_social_',JSField.TEXT_FIELD,0,0,150,20)
	$fld_1.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST | SM_ANCHOR.EAST
	$fld_1.editable = false
	$fld_1.titleText = 'Razon Social'
	
	var $fld_2 = frm.newField('importe_',JSField.TEXT_FIELD,150,0,100,20)
	$fld_2.format = '###,###.00'
	$fld_2.horizontalAlignment = SM_ALIGNMENT.RIGHT
	$fld_2.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST | SM_ANCHOR.EAST
	$fld_2.editable = false
	$fld_2.titleText = 'Importe'
	
	var $fld_3 = frm.newField('saldo_',JSField.TEXT_FIELD,250,0,100,20)
	$fld_3.format = '###,###.00'
	$fld_3.horizontalAlignment = SM_ALIGNMENT.RIGHT
	$fld_3.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST | SM_ANCHOR.EAST
	$fld_3.editable = false
	$fld_3.titleText = 'Saldo'
	
	var $fld_4 = frm.newField('diferencia',JSField.TEXT_FIELD,350,0,100,20)
	$fld_4.format = '###,###.00'
	$fld_4.horizontalAlignment = SM_ALIGNMENT.RIGHT
	$fld_4.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST | SM_ANCHOR.EAST
	$fld_4.editable = false
	$fld_4.titleText = 'Diferencia'
		
	elements.tab_lista.addTab(forms[frm.name])
	//elements.tab_lista.enabled = false
}
